package com.situ.orderingsystem.service.impl;

import com.situ.orderingsystem.dao.KindDao;
import com.situ.orderingsystem.dao.impl.KindDaoImpl;
import com.situ.orderingsystem.model.Kind;
import com.situ.orderingsystem.model.KindSearchBean;
import com.situ.orderingsystem.service.KindService;
import com.situ.orderingsystem.utils.BeanFactory;
import com.situ.orderingsystem.utils.PaginateInfo;

import java.util.List;

public class KindServiceImpl implements KindService {
    private final KindDao dao = BeanFactory.getBean(KindDaoImpl.class);
    @Override
    public List<Kind> findAll(KindSearchBean eb, PaginateInfo pi) {
        return dao.findAll(eb,pi);
    }
    public List<Kind> findAll() {
        return dao.findAll();
    }

    @Override
    public List<Kind> findCombo() {
        return dao.findCombo();
    }

    @Override
    public int deleteByIds(Integer[] ids) {
        int rows=0;
        for(Integer id :ids){
            boolean b = dao.deleteById(id) ;
            if(b){
                rows++;
            }
        }
        return  rows;
    }

    @Override
    public boolean save(Kind employee) {
        return  dao.add(employee) > 0;
    }

    @Override
    public Kind searchById(Integer id) {
        return  dao.searchById(id);
    }

    @Override
    public boolean update(Kind employee) {
        return dao.update(employee)  > 0;
    }
}
